Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Graphics /
Chapter 3 - Geometric Styles / Using Geometric Styles


Using Curve Error When Reducing Shapes

You can also use curve error to eliminate excess detail in complicated shapes. When you call the GXReduceShape or GXSimplifyShape functions, QuickDraw GX averages points within a curve error of each other.

You can use this feature to smooth a complicated contour, such as the wavy line created in Listing 3-6.

Listing 3-6 Creating a complicated contour

void FlattenWavyLine(void)
{
   gxShape aWave;

   static longwavyGeometry[] = {1, /* number of contours */
                                13, /* number of points */
                                0x2AA00000, /* 0010 0101 0101 */
                                ff(80), ff(100),/* on  */
                                ff(110), ff(100),/* on  */
                                ff(113), ff(91), /* off */
                                ff(118), ff(103),/* on  */
                                ff(123), ff(85),/* off */
                                ff(128), ff(100), /* on  */
                                ff(133), ff(112), /* off */
                                ff(135), ff(97), /* on  */
                                ff(141), ff(106), /* off */
                                ff(145), ff(94), /* on  */
                                ff(150), ff(109), /* off */
                                ff(153), ff(100), /* on  */
                                ff(183), ff(100)/* on  */
                               };

   aWave = GXNewPaths((gxPaths *) wavyGeometry);
   GXSetShapeFill(aWave, gxOpenFrameFill);

   GXDrawShape(aWave);

   GXDisposeShape(aWave);
}
The shape created by this sample function is shown in Figure 3-43.

Figure 3-43 Wavy line

If you add the following lines of code to this sample function:

GXSetShapeCurveError(aWave, ff(10));
GXReduceShape(aWave, 0);
the resulting shape has a slightly smoother appearance because QuickDraw GX averages sequential on-curve geometric points within the specified distance (a distance of 10 grid points). Figure 3-44 shows the resulting shape.

Figure 3-44 Wavy line somewhat smoothed by curve error of 10

Increasing the curve error increases the number of geometric points that QuickDraw GX averages. A curve error of 15 results in the shape shown in Figure 3-45.

Figure 3-45 Wavy line smoothed by curve error of 15

A curve error of 20 results in a completely straight line--all of the points between the start point and the end point of the contour have been averaged out as shown in
Figure 3-46.

Figure 3-46 Wavy line completely straightened by curve error of 20

Note
When QuickDraw GX reduces a shape, it does not ignore the first and last points of the contour. If these points had been close enough to the other points in this example, they, too, would have been averaged, and the entire shape would have become a point.
For more information about curve error and the functions you can use to manipulate it, see "Curve Error" on page 3-14 and "Getting and Setting Curve Error" beginning on page 3-114.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help